﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jzy.Core.Common.Basic;
using Jzy.Core.Attach;

namespace ECommerce.Model.Product
{
    public partial class ECProductInfo
    {
        public string Type1Name
        {
            get;
            set;
        }

        public double Depreciate
        {
            get
            {
                return this.OldPrice - this.CurrentPrice;
            }
        }

        public int Index
        {
            get;
            set;
        }

        public string SmallImageAbsPath
        {
            get
            {
                if (!string.IsNullOrEmpty(this.SmallImage))
                {
                    return GlobalVar.WebAppPath + this.SmallImage;
                }
                else
                {
                    return this.SmallImage;
                }
            }
        }

        public string AdImageAbsPath
        {
            get
            {
                if (!string.IsNullOrEmpty(this.AdImage))
                {
                    return GlobalVar.WebAppPath + this.AdImage;
                }
                else
                {
                    return this.AdImage;
                }
            }
        }

        public Func<int, List<ImageInfo>> GetPictures;
        private List<ImageInfo> _pictures;
        public List<ImageInfo> Pictures
        {
            get
            {
                if (_pictures == null)
                {
                    _pictures = GetPictures(this.ID);
                }
                return _pictures;
            }
            set
            {
                _pictures = value;
            }
        }

        public Func<int, List<ECProductCommentInfo>> GetComents;
        private List<ECProductCommentInfo> _comments;
        public List<ECProductCommentInfo> Comments
        {
            get
            {
                if (_comments == null)
                {
                    _comments = GetComents(this.ID);
                }
                return _comments;
            }
            set
            {
                _comments = value;
            }
        }

        public int BuyCount
        {
            get;
            set;
        }
    }
}
